﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using System.Xml;
using DBBase;

namespace Business
{
    public partial class Business18C06 : Form
    {
        public MainForm m_mainform;
        public string ssqm = "";
        public Business18C06()
        {
            InitializeComponent();
        }

        private void but_download_Click(object sender, EventArgs e)
        {
                  string vehispara = "";
            string stoubao = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara = stoubao + string.Format(@"<root><QueryCondition><babh>{0}</babh><gxrq>{1}</gxrq></QueryCondition></root>",
                tb_babh.Text,
                dateTimePicker1.Value.ToString("yyyy-MM-dd"));

            WebReference.Service m_sshenhe18C06 = new WebReference.Service();
            m_sshenhe18C06.Url = m_mainform.surl;
            string str = decode(m_sshenhe18C06.queryObjectOut("18", m_mainform.sSQM, "18C06", vehispara));
            MessageBox.Show(str);
            if (str.Length < 1)
            {
                MessageBox.Show("连接不到服务器");

            }
            else
            {
                XmlDocument xmlstr = new XmlDocument();
                xmlstr.LoadXml(str);
                tb_babh1.Text = xmlstr.SelectSingleNode("/root/body/vehispara/babh").InnerText;
                tb_jcxtmc.Text = xmlstr.SelectSingleNode("/root/body/vehispara/jcxtmc").InnerText;
                tb_jcxxh.Text = xmlstr.SelectSingleNode("/root/body/vehispara/jyxtsm").InnerText;
                tb_bbbh.Text = xmlstr.SelectSingleNode("/root/body/vehispara/bbbh").InnerText;
                tb_kfdw.Text = xmlstr.SelectSingleNode("/root/body/vehispara/kfdw").InnerText;
                tb_sqlbb.Text = xmlstr.SelectSingleNode("/root/body/vehispara/sjkbb").InnerText;
                tb_xtjg.Text = xmlstr.SelectSingleNode("/root/body/vehispara/xtjgms").InnerText;
                tb_jyjgbh.Text=xmlstr.SelectSingleNode("/root/body/vehispara/jczbh").InnerText;
                tb_jcxxh.Text = xmlstr.SelectSingleNode("/root/body/vehispara/jcxxh").InnerText;
                tb_jcsj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/jcsj").InnerText;
                tb_yssj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/yssj").InnerText;
                tb_syzt.Text = xmlstr.SelectSingleNode("/root/body/vehispara/syzt").InnerText;
                tb_ztyy.Text = xmlstr.SelectSingleNode("/root/body/vehispara/ztyy").InnerText;
                tb_jbr.Text = xmlstr.SelectSingleNode("/root/body/vehispara/jbr").InnerText;
                tb_shbj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/shbj").InnerText;
                tb_shyj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/shyj").InnerText;
                tb_shr.Text = xmlstr.SelectSingleNode("/root/body/vehispara/shr").InnerText;
                tb_shsj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/shsj").InnerText;
                tb_fzjg.Text = xmlstr.SelectSingleNode("/root/body/vehispara/fzjg").InnerText;
                tb_glbm.Text = xmlstr.SelectSingleNode("/root/body/vehispara/glbm").InnerText;
                tb_gxsj.Text = xmlstr.SelectSingleNode("/root/body/vehispara/gxsj").InnerText;
                tb_syglbm.Text = xmlstr.SelectSingleNode("/root/body/vehispara/syglbm").InnerText;
            }
        }
        public string decode(string str)//utf8转中文
        {
            Encoding utf8 = Encoding.UTF8;
            // 首先用utf-8进行解码                    
            return HttpUtility.UrlDecode(str.ToUpper(), utf8);
        }
        public string encode(string str)//中文转utf8
        {
            Encoding utf8 = Encoding.UTF8;
            return HttpUtility.UrlEncode(str, utf8);
        }
        private void Business18C06_Load(object sender, EventArgs e)
        {
            getdata();
        }
        public void getdata()
        {
             Query mquery = new Query();
             string sql = string.Format("select * from Business18C06 ");
            DataTable dt = mquery.GetTable(sql);
            if (dt.Rows.Count > 0)
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {

                    tb_babh1.Text = dt.Rows[i]["babh"].ToString().Trim();
                    tb_jcxtmc.Text = dt.Rows[i]["jyxtmc"].ToString().Trim();
                    tb_xtsm.Text = dt.Rows[i]["jyxtsm"].ToString().Trim();
                    tb_bbbh.Text = dt.Rows[i]["bbbh"].ToString().Trim();
                    tb_kfdw.Text = dt.Rows[i]["kfdw"].ToString().Trim();
                    tb_sqlbb.Text = dt.Rows[i]["sjkbb"].ToString().Trim();
                    tb_xtjg.Text = dt.Rows[i]["xtjgms"].ToString().Trim();
                    tb_jyjgbh.Text = dt.Rows[i]["jczbh"].ToString().Trim();
                    tb_jcxxh.Text = dt.Rows[i]["jcxxh"].ToString().Trim();
                    tb_jcsj.Text = dt.Rows[i]["jcsj"].ToString().Trim();
                    tb_yssj.Text = dt.Rows[i]["yssj"].ToString().Trim();
                    tb_syzt.Text = dt.Rows[i]["syzt"].ToString().Trim();
                    tb_ztyy.Text = dt.Rows[i]["ztyy"].ToString().Trim();
                    tb_jbr.Text = dt.Rows[i]["jbr"].ToString().Trim();
                    tb_shbj.Text = dt.Rows[i]["shbj"].ToString().Trim();
                    tb_shyj.Text = dt.Rows[i]["shyj"].ToString().Trim();
                    tb_shr.Text = dt.Rows[i]["shr"].ToString().Trim();
                    tb_shsj.Text = dt.Rows[i]["shsj"].ToString().Trim();
                    tb_fzjg.Text = dt.Rows[i]["fzjg"].ToString().Trim();
                    tb_glbm.Text = dt.Rows[i]["glbm"].ToString().Trim();
                    tb_gxsj.Text = dt.Rows[i]["gxsj"].ToString().Trim();
                    tb_syglbm.Text = dt.Rows[i]["syglbm"].ToString().Trim();

                   
                }
            }
        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            string vehispara = "";
            string stoubao = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara = stoubao + string.Format(@"<root><QueryCondition><jczbh>{0}</jczbh><yyrq>{1}</yyrq></QueryCondition></root>",
                tb_babh.Text,
                dateTimePicker1.Value.ToString("yyyy-MM-dd"));

            WebReference.Service m_sshenhe18C06 = new WebReference.Service();
            m_sshenhe18C06.Url = m_mainform.surl;
            string str = decode(m_sshenhe18C06.queryObjectOut("18", m_mainform.sSQM, "18C07", vehispara));
            MessageBox.Show(str);
        }

        private void skinButton2_Click(object sender, EventArgs e)
        {
            string vehispara = "";
            string stoubao = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara = stoubao + string.Format(@"<root><QueryCondition><zpbh>{0}</zpbh></QueryCondition></root>",
                "0352"
                );

            WebReference.Service m_sshenhe18C06 = new WebReference.Service();
            m_sshenhe18C06.Url = m_mainform.surl;
            string str = decode(m_sshenhe18C06.queryObjectOut("18", m_mainform.sSQM, "18C09", vehispara));
            MessageBox.Show(str);
        }

        private void skinButton3_Click(object sender, EventArgs e)
        {
            string vehispara = "";
            string stoubao = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara = stoubao + string.Format(@"<root><QueryCondition><bh>{0}</bh><clpp1>{1}</clpp1><clxh>{2}</clxh></QueryCondition></root>",
                "WAA09V400072261",
                encode("解放牌"),
                "CA4250P66K24T1A1E5");

            WebReference.Service m_sshenhe18C06 = new WebReference.Service();
            m_sshenhe18C06.Url = m_mainform.surl;
            string str = decode(m_sshenhe18C06.queryObjectOut("18", m_mainform.sSQM, "18C08", vehispara));
            MessageBox.Show(str);
        }
    }
}
